#include "ping_protocol.hpp"
#include "../core/di_container.hpp"
#include "../common/logger.hpp"
#include "../core/game_server.hpp"

namespace protocols {

PingProtocol::PingProtocol() {
    Logger::info("PingProtocol created");
}

PingProtocol::~PingProtocol() {
    Logger::info("PingProtocol destroyed");
}

bool PingProtocol::validate(GameServer& game_server, const nlohmann::json& message, uint32_t session_id) {
    return true;
}

void PingProtocol::process(GameServer& game_server, const nlohmann::json& message, uint32_t session_id) {
    Logger::info("PingProtocol process");

    // 发送ping消息
    nlohmann::json ping_message = {
         {"type", "ping"},
         {"timestamp", std::chrono::system_clock::now().time_since_epoch().count()}
     };
     game_server.send_message(session_id, ping_message);
}

} // namespace protocols